package com.deco.back.controller.fix;

import javax.jws.WebParam;
import javax.servlet.http.HttpServletRequest;

import com.free.common.vo.PageResponseVo;
import com.free.common.vo.PageSearchVo;
import com.free.ext.shiro.SessionManager;
import com.free.ext.web.spring.annoation.PageSearch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.deco.domain.vo.fix.FixGeneralVo;
import com.deco.domain.vo.fix.FixTypeVo;
import com.deco.service.fix.FixGeneralService;
import com.deco.service.fix.FixTypeService;
import com.free.common.vo.ResultModel;
import org.springframework.web.servlet.ModelAndView;

/**
 * 广告管理 Controller
 * @author lengy
 *
 */
@Controller
public class FixTypeController {
    @Autowired
    private FixTypeService fixTypeService;

    @RequestMapping(value = "/fix_type_list.do")
    public ModelAndView fixTypeList(){
        ModelAndView mv = new ModelAndView("fix/fixtypelist");
        return mv;
    }

    @RequestMapping(value= "/fix_type_list_page.do")
    @ResponseBody
    public PageResponseVo<FixTypeVo> getList(@PageSearch PageSearchVo<FixTypeVo> condition){
        return fixTypeService.pageInfo(condition);
    }

    @RequestMapping(value = "/fix_type_edit.do")
    public ModelAndView editFixType(Integer id){
        FixTypeVo vo = null;
        ModelAndView mv = new ModelAndView("fix/fixtypeedit");
        if(id != null){
            vo = fixTypeService.getFixType(id);
            mv.addObject("actNm","更新");
        }else{
            vo = new FixTypeVo();
            vo.setId(0);
            mv.addObject("actNm","新增");
        }
        mv.addObject("obj",vo);
        return mv;
    }

    @RequestMapping(value ="/fix_type_del.do")
    @ResponseBody
    public ResultModel batchDelete(@RequestParam(value = "ids[]")Integer[] ids){
        return fixTypeService.batchDelete(ids);
    }

    @RequestMapping(value ="/fix_type_edit_submit.do")
    @ResponseBody
    public ResultModel udpate(FixTypeVo vo){
        return fixTypeService.save(vo);
    }

    @RequestMapping(value ="/fix_type_name.do")
    @ResponseBody
    public ResultModel isNameValid(Integer id, String typeName){
        return fixTypeService.isNameValid(id,typeName);
    }

    @RequestMapping(value ="/fix_type_status.do")
    @ResponseBody
    public ResultModel updateStatus(FixTypeVo vo){
        return fixTypeService.save(vo);
    }

}
